<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>UCenter Administrator's Control Panel</title>
        <link rel="stylesheet" href="css/common.css" type="text/css" media="all" />
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript">
            function delit(id){
                document.getElementById("opid").value = id;
                opform.submit();
            }
            function getclassmenu(obj){
                var module_type = obj.value;
                var urlstr = "index.php?c=Ajax&a=GetClass&module_type="+module_type;
                $.ajax({
                    url:urlstr,
                    type:"get",
                    success:function(data){
                        var obj = eval(data);
                        var option_str = '<option value="0">选择类别</option>';
                        $.each(obj,function(k,v){
                            option_str += '<option value="'+v.id+'">'+v.name+'</option>'
                        });
                        $("#classid").html(option_str);
                    }
                });
            }
            function getsubclassmenu(obj){
                var module_type = $("#module_type").val();
                var classid = obj.value;
                var urlstr = "index.php?c=Ajax&a=GetSubClass&module_type="+module_type+"&classid="+classid;

                $.ajax({
                    url:urlstr,
                    type:"get",
                    success:function(data){
                        var obj = eval(data);
                        var option_str = '<option value="0">选择子类</option>';
                        $.each(obj,function(k,v){
                            option_str += '<option value="'+v.id+'">'+v.name+'</option>'
                        });
                        $("#subclassid").html(option_str);
                    }
                });
            }
        </script>
    </head>
    <body>
        <div id="append"></div>


        <div class="container">
            <div>
                <div style="text-align: left;">
                    <h2 class="admintitle">类别管理</h2>
                    <div class="adminserach">
                    <form name="sform" method="post" action="">
                       搜索： <select name="m_type" style="width:200px;">
                            <option value="0">选择模块</option>
                            <?php
                            if (!empty($module_list) && is_array($module_list)) {
                                foreach ($module_list as $mid => $mname) {
                                    if ($m_type == $mid) {
                                        echo '<option value="' . $mid . '" selected>' . $mname . '</option>';
                                    } else {
                                        echo '<option value="' . $mid . '">' . $mname . '</option>';
                                    }
                                }
                            }
                            ?>
                        </select>
                        <input type="submit" name="search" value="搜索" />
                    </form>
                    </div>
                </div>
                <div id="srchuserdiv" class="tabcontentcurrent">
                    <form name="opform" action="index.php?c=ModuleManage&a=DelModule" method="post">
                        <input type="hidden" id="opid" name="opid" value="0" />
                        <table width="100%">
                            <tr>
                                <td>id:</td>
                                <td>模块名</td>
                                <td>类名</td>
                                <td>操作</td>
                            </tr>
                            <?php
                            if (!empty($list) && is_array($list)) {
                                foreach ($list as $val) {
                                    $id = $val['id'];
                                    $module_type = $val['module_type'];
                                    $module_name = $module_list[$module_type];
                                    $name = $val['name'];
                                    $classid = $val['classid'];
                                    $subclassid = $val['subclassid'];
                                    echo '<tr><td>' . $id . '</td>
                                              <td>' . $name . '</td>
                                              <td>' . $module_name . '</td>
                                              <td><input type="button" name="delete" onclick="delit(' . $id . ')" value="删除" /></td></tr>';
                                }
                            }
                            ?>
                        </table>
                    </form>
                </div>
                <?php
                            if ($totalpage > 1) {
                                echo '<div class="pagelist">';

                                if ($totalpage <= 10) {
                                    for ($i = 1; $i <= $page; $i++) {
                                        if ($page == $i) {
                                            echo '<span>' . $i . '</span>';
                                        } else {
                                            echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $i . '">' . $i . '</a>';
                                        }
                                    }
                                } else {
                                    if ($page - 2 <= 1) {
                                        for ($i = 1; $i <= $page; $i++) {
                                            if ($i == $page) {
                                                echo '<span>' . $i . '</span>';
                                            } else {
                                                echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $i . '">' . $i . '</a>';
                                            }
                                        }
                                    } else {
                                        echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=1">1</a>...';
                                        for ($i = $page - 2; $i <= $page; $i++) {
                                            if ($i == $page) {
                                                echo '<span>' . $i . '</span>';
                                            } else {
                                                echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $i . '">' . $i . '</a>';
                                            }
                                        }
                                    }

                                    if ($page + 2 < $totalpage) {
                                        for ($i = $page + 1; $i < $page + 3; $i++) {
                                            echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $i . '">' . $i . '</a>';
                                        }
                                        echo '...<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $totalpage . '">' . $totalpage . '</a>';
                                    } else {
                                        for ($i = $page + 1; $i <= $totalpage; $i++) {
                                            echo '<a href="?c=categoryManage&m_type=' . $m_type . '&page=' . $i . '">' . $i . '</a>';
                                        }
                                    }
                                }
                                echo '</div>';
                            }
                ?>
                        </div>

                        <br />
            <?php
                            if (empty($list)) {
            ?>
                                <div class="mainbox">
                                    <div class="note">
                                        <p class="i">目前没有相关数据!</p>
                                    </div>
                                </div>
            <?php
                            }
            ?>

                        </div>
                        <div style="width:580px;padding:10px 0;">
                            <form name="opform" action="index.php?c=CategoryManage" method="post">
                               添加： <select name="module_type" id="module_type" onchange="getclassmenu(this)"><option value="0">选择模块</option>
                    <?php
                            if (!empty($module_list) && is_array($module_list)) {
                                foreach ($module_list as $mid => $mname) {
                                    echo '<option value="' . $mid . '">' . $mname . '</option>';
                                }
                            }
                    ?>
                </select>
                <select name="classid" id="classid" onchange="getsubclassmenu(this)"><option value="0">选择类别</option>
                </select>
<!--                    <select name="subclassid" id="subclassid"><option value="0">选择子类</option>
                </select>-->
                <input type="text" name="name" value="" />
                <input type="submit" name="categoryadd" value="提 交" />
            </form>
        </div>

    </body>
</html>
